package com.ruoyi.project.yuwen.topmanlog.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.yuwen.topmanlog.domain.AudioTopmanLog;
import com.ruoyi.project.yuwen.topmanlog.service.IAudioTopmanLogService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 达人日志Controller
 * 
 * @author shixiangwen
 * @date 2021-03-19
 */
@Controller
@RequestMapping("/yuwen/topmanlog")
public class AudioTopmanLogController extends BaseController
{
    private String prefix = "yuwen/topmanlog";

    @Autowired
    private IAudioTopmanLogService audioTopmanLogService;

    @RequiresPermissions("yuwen:topmanlog:view")
    @GetMapping()
    public String topmanlog()
    {
        return prefix + "/topmanlog";
    }

    /**
     * 查询达人日志列表
     */
    @RequiresPermissions("yuwen:topmanlog:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(AudioTopmanLog audioTopmanLog)
    {
        startPage();
        List<AudioTopmanLog> list = audioTopmanLogService.selectAudioTopmanLogList(audioTopmanLog);
        return getDataTable(list);
    }

    /**
     * 导出达人日志列表
     */
    @RequiresPermissions("yuwen:topmanlog:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(AudioTopmanLog audioTopmanLog)
    {
        List<AudioTopmanLog> list = audioTopmanLogService.selectAudioTopmanLogList(audioTopmanLog);
        ExcelUtil<AudioTopmanLog> util = new ExcelUtil<AudioTopmanLog>(AudioTopmanLog.class);
        return util.exportExcel(list, "topmanlog");
    }

    /**
     * 新增达人日志
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存达人日志
     */
    @RequiresPermissions("yuwen:topmanlog:add")
    @Log(title = "达人日志", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(AudioTopmanLog audioTopmanLog)
    {
        return toAjax(audioTopmanLogService.insertAudioTopmanLog(audioTopmanLog));
    }

    /**
     * 修改达人日志
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        AudioTopmanLog audioTopmanLog = audioTopmanLogService.selectAudioTopmanLogById(id);
        mmap.put("audioTopmanLog", audioTopmanLog);
        return prefix + "/edit";
    }

    /**
     * 修改保存达人日志
     */
    @RequiresPermissions("yuwen:topmanlog:edit")
    @Log(title = "达人日志", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(AudioTopmanLog audioTopmanLog)
    {
        return toAjax(audioTopmanLogService.updateAudioTopmanLog(audioTopmanLog));
    }

    /**
     * 删除达人日志
     */
    @RequiresPermissions("yuwen:topmanlog:remove")
    @Log(title = "达人日志", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(audioTopmanLogService.deleteAudioTopmanLogByIds(ids));
    }
}
